/*
 * @Author: your name
 * @Date: 2021-12-21 13:51:13
 * @LastEditTime: 2021-12-21 14:02:08
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \first_one_file\react-travel\src\redux\language\languageActions.ts
 */
export const CHANGE_LANGUAGE = "change_language";
export const ADD_LANGUAGE = "add_language";

interface ChangeLanguageAction {
  type: typeof CHANGE_LANGUAGE,
  payload: "zh" | "en"
}

interface AddLanguageAction {
  type: typeof ADD_LANGUAGE,
  payload: { name: string, code: string }
}

export type LanguageActionTypes = ChangeLanguageAction | AddLanguageAction;

export const changeLanguageActionCreator = (languageCode: "zh" | "en") : ChangeLanguageAction => {
  return {
    type: CHANGE_LANGUAGE,
    payload: languageCode
  }
}

export const addLanguageActionCreator = (name: string, code: string) : AddLanguageAction => {
  return {
    type: ADD_LANGUAGE,
    payload: { name, code }
  }
}
